<div class="layui-card index">
    <fieldset class="layui-elem-field index-box">
        <legend>便捷操作</legend>
        <div class="layui-elem-quote layui-quote-nm">
            <p>配置缓存时长是<span id="cache_time">0</span></p>
        </div>
        <div class="layui-field-box index-btn-list" style="margin-top: 30px">
            <div class="index-btns">
                <button class="layui-btn layui-btn-primary" id="reload" data-tip="重启Work和Task的所有进程">
                    <i class="layui-icon layui-icon-refresh-3"></i>
                    热重启服务
                </button>
                <button class="layui-btn layui-btn-primary" id="reset">
                    <i class="layui-icon layui-icon-set-fill"></i>
                    强制刷新系统配置
                </button>

            </div>
        </div>

    </fieldset>
</div>
<script>
    let timer ,  b_txt_i = '重启中';
    $('#reload').click(function () {
        const _this = this;
        const arg = {
            _this:_this,
            url:'/admin/set/reload.htm',
            i:3
        }
        reload(arg)
    })
      $('#reset').click(function () {
          layer.msg('未开发')
      });



function reload ({_this,url,i}) {
         let t = i || 5
         let b_txt = $(_this).html()
         layer.confirm('你确定重启吗？',function (index) {
             $(_this).attr('disabled',true).addClass('layui-btn-disabled')
             http.get(url).done(function (res) {
                 layer.msg(res.msg)
                 timer = setInterval(function () {
                     if( t <= 0 ) {
                         $(_this).html(b_txt).attr('disabled',false)
                             .removeClass('layui-btn-disabled')
                         clearInterval(timer);
                     } else {
                         t--
                         $(_this).text(b_txt_i+'('+t+'秒)')
                     }
                 },1000)
             })
         })
     };
</script>